package com.baobaotao.advice;

import org.springframework.aop.BeforeAdvice;
import org.springframework.aop.framework.ProxyFactory;

public class TestBeforeAdvice {

	public static void main(String[] args) {
		Waiter targer=new NaiveWaiter();
		BeforeAdvice advice=new GreetingBeforeAdvice();
		//spring提供的代理工厂
		ProxyFactory pf=new ProxyFactory();
		//设置代理目标
		pf.setTarget(targer);
		//为代理目标增加增强
		pf.addAdvice(advice);
		
		Waiter proxy=(Waiter)pf.getProxy();
		proxy.greetTo("jiaguangxu");
		proxy.serveTo("jiaguangxu");
		

	}

}
